﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using DWF.Studio.Models;
using DWF.Studio.NuGetManagement;
using DWF.Studio.Project;
using DWF.Studio.Script;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace DWF.Studio.Custom
{
    /// <summary>
    /// 全局事件Action处理类
    /// </summary>
    internal static class GlobalActionHandler
    {
        #region 界面
        /// <summary>
        /// 设置状态栏信息
        /// </summary>
        public static Action<TagEventArgs<string>> SetStatusBarMsg;
        #endregion

        #region 工程
        /// <summary>
        /// 工程打开
        /// </summary>
        public static Action<TagEventArgs<string>> ProjectOpen;
        /// <summary>
        /// 刷新工程名
        /// </summary>
        public static Action<TagEventArgs<string>> RefreshTitleName;

        /// <summary>
        /// 工程打开完成
        /// </summary>
        public static Action<TagEventArgs<ProjectInfo>> ProjectOpened;

        /// <summary>
        /// 工程创建
        /// </summary>
        public static Action<TagEventArgs<string, string, string, string, string>> ProjectCreate;

        /// <summary>
        /// 工程预关闭
        /// </summary>
        public static Action<CancelEventArgs> ProjectPreclose;
        /// <summary>
        /// 工程关闭
        /// </summary>
        public static Action<EventArgs> ProjectClosing;
        /// <summary>
        /// 返回startpage(不关闭工程)
        /// </summary>
        public static Action<TagEventArgs<bool>> BackStartPage;
        #endregion

        #region 脚本
        /// <summary>
        /// 脚本运行
        /// </summary>
        public static Action<EventArgs> ScriptRun;

        /// <summary>
        /// 脚本整体运行
        /// </summary>
        public static Action<EventArgs> AllScriptRun;

        /// <summary>
        /// 脚本停止
        /// </summary>
        public static Action<EventArgs> ScriptStop;

        /// <summary>
        /// 脚本保存
        /// </summary>
        public static Func<EventArgs, bool> ScriptSave;

        /// <summary>
        /// 脚本全部保存
        /// </summary>
        public static Func<EventArgs, bool> AllScriptSave;

        /// <summary>
        /// 脚本自动保存
        /// </summary>
        public static Action<EventArgs> ScriptAutoSave;

        /// <summary>
        /// 脚本显示
        /// </summary>
        public static Action<TagEventArgs<ProjectFile>> ScriptShow;

        /// <summary>
        /// 脚本选择
        /// </summary>
        public static Action<TagEventArgs<ScriptBase>> ScriptSelected;

        /// <summary>
        /// 脚本重命名
        /// </summary>
        public static Action<TagEventArgs<ProjectFile, string>> ScriptRename;

        /// <summary>
        /// 脚本删除
        /// </summary>
        public static Action<TagEventArgs<ProjectFile>> ScriptDelete;

        /// <summary>
        /// 发布工程
        /// </summary>
        public static Action<EventArgs> ProjectDeploy;
        #endregion

        #region 活动
        /// <summary>
        /// 添加活动
        /// </summary>
        public static Func<string, string, IDictionary<string, object>, string> AddActivityToWorkflow;

        /// <summary>
        /// 获取根活动类型名
        /// </summary>
        public static Func<string> GetRootActivityTypeName;

        /// <summary>
        /// 获取根活动Id
        /// </summary>
        public static Func<string> GetRootActivityCode;

        public static Action<string, IDictionary<string, object>> SetActivityByCode;

        /// <summary>
        /// 活动包被选择
        /// </summary>
        public static Action<TagEventArgs<NugetPackageWrap>> PackageSelected;

        /// <summary>
        /// 活动包安装状态改变
        /// </summary>
        public static Action<TagEventArgs<NugetPackageWrap>> PackageWrapPrechange;

        /// <summary>
        /// 活动包预改变
        /// </summary>
        public static Action<EventArgs> PackagePrechange;

        /// <summary>
        /// 活动包改变
        /// </summary>
        public static Action<EventArgs> PackageChanging;

        /// <summary>
        /// 活动包改变完成
        /// </summary>
        public static Action<EventArgs> PackageChanged;

        /// <summary>
        /// 关闭当前文件
        /// </summary>
        //public static Action<EventArgs> CurrentFileClose;
        #endregion

        #region 片段
        /// <summary>
        /// 片段显示
        /// </summary>
        public static Action<TagEventArgs<SnippetFile>> SnippetScriptShow;
        /// <summary>
        /// 重新加载片段
        /// </summary>
        public static Action<EventArgs> SnippetReload;
        /// <summary>
        /// 修复片段依赖活动
        /// </summary>
        public static Action<TagEventArgs<string>> RepairSnippetActivity;

        /// <summary>
        /// 检查片段依赖活动
        /// </summary>
        public static Action<EventArgs> CheckSnippetActivity;
        /// <summary>
        /// 片段覆盖提示
        /// </summary>
        public static Action<TagEventArgs<string,string, string>> IsCoverSnippet;
        #endregion

        #region 操作命令
        /// <summary>
        /// 剪切操作
        /// </summary>
        public static Action<EventArgs> Cut;

        /// <summary>
        /// 拷贝操作
        /// </summary>
        public static Action<EventArgs> Copy;

        /// <summary>
        /// 粘贴操作
        /// </summary>
        public static Action<EventArgs> Paste;

        /// <summary>
        /// 撤消
        /// </summary>
        public static Action<EventArgs> Undo;

        /// <summary>
        /// 重做
        /// </summary>
        public static Action<EventArgs> Redo;

        /// <summary>
        /// 查找
        /// </summary>
        public static Action<EventArgs> Find;

        /// <summary>
        /// 替换
        /// </summary>
        public static Action<EventArgs> Replace;

        /// <summary>
        /// 搜索活动文本框
        /// </summary>
        public static Action<EventArgs> FindSearchText;
        /// <summary>
        /// 查找脚本 设置脚本焦点
        /// </summary>
        public static Action<TagEventArgs<string, string, string>> SelectionActivity;
        /// <summary>
        /// 注释
        /// </summary>
        public static Action<EventArgs> Notes;
        /// <summary>
        /// 取消注释
        /// </summary>
        public static Action<EventArgs> CancelNotes;

        #endregion

        #region 调试
        public static Action<EventArgs> BreakPointToggle;
        /// <summary>
        /// 刷新断点列表
        /// </summary>
        public static Action<EventArgs> BreakPointFresh;

        public static Action<EventArgs> ScriptDebug;

        public static Action<EventArgs> ScriptDebugByStep;
        /// <summary>
        /// 校验脚本，输入字符串择为输入的页面，如果为空择全部检索
        /// </summary>
        public static Action<TagEventArgs<string>> ValidateScript;
        #endregion

        #region 面板切换操作指令
        /// <summary>
        /// 打开关闭工程面板
        /// </summary>
        public static Action<EventArgs> SwitchProjectPanel;
        /// <summary>
        /// 打开关闭活动面板
        /// </summary>
        public static Action<EventArgs> SwitchActivityPanel;
        /// <summary>
        /// 打开关闭片段面板
        /// </summary>
        public static Action<EventArgs> SwitchSnippetPanel;
        /// <summary>
        /// 打开关闭属性面板
        /// </summary>
        public static Action<EventArgs> SwitchAttributePanel;
        /// <summary>
        /// 打开关闭大纲面板
        /// </summary>
        public static Action<EventArgs> SwitchOutlinePanel;
        /// <summary>
        /// 打开关闭日志面板
        /// </summary>
        public static Action<EventArgs> SwitchLogPanel;
        /// <summary>
        /// 调整主面板宽度
        /// </summary>
        public static Action<TagEventArgs<bool>> ChangePropertyRegionWidth;
        #endregion

        /// <summary>
        /// WF参数联动
        /// </summary>
        public static Action<TagEventArgs<ProjectParam,int>> SetPutParam;
        /// <summary>
        /// WF参数联动(多个)
        /// </summary>
        public static Action<TagEventArgs<List<ProjectParam>>> SetPutParams;
        /// <summary>
        /// 刷新参数
        /// </summary>
        public static Action<ArgumentEventArgs> LoadPutParam;

        public static Action<EventArgs> ProjectRecordsRefresh;


        /// <summary>
        /// 信息输出
        /// </summary>
        public static Action<TagEventArgs<string>> MsgOutput;
    }
}



